package com.hd.trans.utils;

import android.os.Build;
import android.os.Environment;

import com.hd.trans.ui.base.AppContextProvider;

import java.io.File;

/**
 * Desc:  视频路径
 */
public final class MediaFileUtil {

    private static final String MEDIA_ORIG_PATH = "SDK/Media/Orig/";

    private static final String MEDIA_TARGET_PATH = "SDK/Media/Target/";

    private static final String MEDIA_DOWNLOAD_PATH = "SDK/Media/Download/";

    public static String getCacheRoot(){
        String path;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
            path = AppContextProvider.getContext().getFilesDir().getAbsolutePath() + "/";
        }else {
            path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
        }
        return path;
    }

    public static String getMediaOrigPath() {
        String path = getCacheRoot() + MEDIA_ORIG_PATH;
        File output = new File(path);
        if (!output.exists()) {
            output.mkdirs();
        }
        return path;
    }

    public static String getMediaTargetPath() {
        String path = getCacheRoot() + MEDIA_TARGET_PATH;
        File output = new File(path);
        if (!output.exists()) {
            output.mkdirs();
        }
        return path;
    }

    public static String getMediaDownloadPath() {
        String path = getCacheRoot() + MEDIA_DOWNLOAD_PATH;
        File output = new File(path);
        if (!output.exists()) {
            output.mkdirs();
        }
        return path;
    }
}
